//3.创建线程的方法：继承Thread，重写run，调用start  见demo2
public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        //通过匿名内部类的方式，创建线程
        Thread t=new Thread() {
            @Override
            public void run() {
                while(true) {
                    System.out.println("hello Thread匿名");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        //仍然需要通过start启动线程
        t.start();
        while(true) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
